package com.sun.net;

import java.util.List;
import android.os.Handler;

public class LinkServer extends BaseDao
{

	public LinkServer(Handler handler)
	{
		super(handler);
	}

	/**
	 * 开奖详细信息
	 * 
	 * @param lotid
	 *            彩票类型
	 * @param expect
	 *            查询期号
	 * @return
	 *         当集合第一项为000时 查询成功 值依次为 响应编号 响应提示 期号 开奖号 开奖时间 当前销售量 奖池 奖项 中奖注数 每注奖金
	 *         快频彩种 只有
	 *         期号 开奖号 开奖时间
	 */
	public void SearchKaiJiangDetail(int lotid, String expect, HttpListener listener)
	{
		String time = GetCurrentTime();
		StringBuffer requestBuffer = new StringBuffer();
		requestBuffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><qkjxxreq>");
		requestBuffer.append("<partner>80003</partner><lotid>");
		requestBuffer.append(lotid);
		requestBuffer.append("</lotid><expect>");
		requestBuffer.append(expect);
		requestBuffer.append("</expect><timestamp>");
		requestBuffer.append(time);
		requestBuffer.append("</timestamp><sign>");
		requestBuffer.append(GetMD5(time));
		requestBuffer.append("</sign></qkjxxreq>");
		String requestContent = initParameter(requestBuffer.toString());
		Redo(requestContent,listener);
		
	}

	
	/**
	 * 查询当前期号信息
	 * 
	 * @param lotid
	 *            彩票类型
	 * @param active
	 *            1当前期，0 返回在售期列表，包含预售期
	 * @return
	 *         当集合第一项为000时 查询成功 值依次为 响应编号 响应提示 从数组第3项开始值依次为:期号 当前期截止时间
	 *         开奖状态(1开奖中，0为正常销售，快频用到) 售票情况(1当前期，0预售期)
	 *         <item>
	 *         <expect>2012029</expect>
	 *         <endtime>2012-03-13 19:50</endtime>
	 *         <active>0</active>
	 *         <issale>0</issale>
	 *         <servertime>2012-03-10 02:40:22</servertime>
	 *         </item>
	 */
	public void GetIssue(int lotid, int active, HttpListener listener)
	{
		String time = GetCurrentTime();
		StringBuffer requestBuffer = new StringBuffer();
		requestBuffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><qclreq>");
		requestBuffer.append("<partner>80003</partner><lotid>");
		requestBuffer.append(lotid);
		requestBuffer.append("</lotid><active>");
		requestBuffer.append(active);
		requestBuffer.append("</active><timestamp>");
		requestBuffer.append(time);
		requestBuffer.append("</timestamp><sign>");
		requestBuffer.append(GetMD5(time));
		requestBuffer.append("</sign></qclreq>");
		String requestContent = initParameter(requestBuffer.toString());
		Redo(requestContent, listener);
	}

	/**
	 * 开奖号码查询
	 * 
	 * @param lotid
	 *            彩票类型
	 * @param pagesize
	 *            每页显示条数
	 * @param page
	 *            页码
	 * @return
	 *         当集合第一项为000时 查询成功 值依次为 响应编号 响应提示 总记录数 总页数 从第5项开始值依次为: 期号 开奖号 开奖时间
	 */
	public void SearchBeckerInfo(int lotid, int pagesize, int page, HttpListener listener)
	{
		String time = GetCurrentTime();
		StringBuffer requestBuffer = new StringBuffer();
		requestBuffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><qkjhreq>");
		requestBuffer.append("<partner>80003</partner><lotid>");
		requestBuffer.append(lotid);
		requestBuffer.append("</lotid><pagesize>");
		requestBuffer.append(pagesize);
		requestBuffer.append("</pagesize><page>");
		requestBuffer.append(page);
		requestBuffer.append("</page><timestamp>");
		requestBuffer.append(time);
		requestBuffer.append("</timestamp><sign>");
		requestBuffer.append(GetMD5(time));
		requestBuffer.append("</sign></qkjhreq>");
		String requestContent = initParameter(requestBuffer.toString());
		Redo(requestContent, listener);
	}

	/**
	 * 走势图列表查询
	 * 
	 * @param lotid
	 *            彩票类型
	 * @param playid
	 *            玩法类型
	 * @return
	 *         当集合第一项为000时 查询成功 值依次为 响应编号 响应提示 从第3项开始值依次为:走时id 走势名称 图片地址4
	 */
	public void SearchZSListInfos(int lotid, int playid, HttpListener listener)
	{
		String time = GetCurrentTime();
		StringBuffer requestBuffer = new StringBuffer();
		requestBuffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><qtireq>");
		requestBuffer.append("<partner>80003</partner><lotid>");
		requestBuffer.append(lotid);
		requestBuffer.append("</lotid><playid>");
		requestBuffer.append(playid);
		requestBuffer.append("</playid><imgsize>");
		requestBuffer.append("</imgsize><timestamp>");
		requestBuffer.append(time);
		requestBuffer.append("</timestamp><sign>");
		requestBuffer.append(GetMD5(time));
		requestBuffer.append("</sign></qtireq>");
		String requestContent = initParameter(requestBuffer.toString());
		Redo(requestContent, listener);
	}

	public static boolean servertrue(List<String> list)
	{
		if (list.get(0).equals("000"))
		{
			return true;
		}
		return false;
	}
}
